#include <vector>
#include <unordered_map>
using namespace std;



int subarraySum(vector<int>& nums, int k) {
	unordered_map<int, int> m;
	m[0] = 1;
	int sum = 0;
	int ans = 0;
	for (size_t i = 0; i < nums.size(); i++)
	{
		sum += nums[i];
		
		if (m.find(sum - k) != m.end()) {
			ans += m[sum - k];
		}
		m[sum]++;
	}
	return ans;
}